import Vue from "vue"; //导入VUE模块
import VueRouter from "vue-router"; //导入路由模块
import HomeView from "../views/HomeView.vue"; //导入Home单文件组件
import Admin from "../views/admin/index.vue";
import Welcome from "../views/admin/welcome.vue";
import Users from "../views/users/index.vue";
import UsersCreate from "../views/users/create.vue";
import Login from "../views/login/index.vue";
import LoginSMS from "../views/login/sms.vue";
import LoginToken from "../views/login/token.vue";

Vue.use(VueRouter);

const routes = [
  // 语法{path,name,component,alias,redirect,meta,children ... }
  // 留心：导入可以【上文】方式，也可以用【下文】方式
  {
    path: "/",
    // name: "home",
    component: Admin,
    children: [
      {
        path: "welcome",
        alias: "/",
        component: Welcome,
      },
      {
        path: "users",

        component: Users,
      },
      {
        path: "users/create",

        component: UsersCreate,
      },
    ],
  },
  {
    path: "/login",

    component: Login,
  },
  {
    path: "/login/sms",

    component: LoginSMS,
  },
  {
    path: "/login/token",

    component: LoginToken,
  },
  {
    path: "/about",
    name: "about",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  },
];

const router = new VueRouter({
  routes,
});

export default router;
